package cn.source.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.source.common.annotation.Log;
import cn.source.common.core.controller.BaseController;
import cn.source.common.core.domain.AjaxResult;
import cn.source.common.enums.BusinessType;
import cn.source.system.domain.AaGoods;
import cn.source.system.service.IAaGoodsService;
import cn.source.common.utils.poi.ExcelUtil;
import cn.source.common.core.page.TableDataInfo;

/**
 * 视频管理Controller
 * 
 * @author sourcebyte.vip
 * @date 2023-08-04
 */
@RestController
@RequestMapping("/cms/goods")
public class AaGoodsController extends BaseController
{
    @Autowired
    private IAaGoodsService aaGoodsService;

    /**
     * 查询视频管理列表
     */
    @PreAuthorize("@ss.hasPermi('cms:goods:list')")
    @GetMapping("/list")
    public TableDataInfo list(AaGoods aaGoods)
    {
        startPage();
        List<AaGoods> list = aaGoodsService.selectAaGoodsList(aaGoods);
        return getDataTable(list);
    }

    /**
     * 导出视频管理列表
     */
    @PreAuthorize("@ss.hasPermi('cms:goods:export')")
    @Log(title = "视频管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AaGoods aaGoods)
    {
        List<AaGoods> list = aaGoodsService.selectAaGoodsList(aaGoods);
        ExcelUtil<AaGoods> util = new ExcelUtil<AaGoods>(AaGoods.class);
        util.exportExcel(response, list, "视频管理数据");
    }

    /**
     * 获取视频管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('cms:goods:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(aaGoodsService.selectAaGoodsById(id));
    }

    /**
     * 新增视频管理
     */
    @PreAuthorize("@ss.hasPermi('cms:goods:add')")
    @Log(title = "视频管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AaGoods aaGoods)
    {
        return toAjax(aaGoodsService.insertAaGoods(aaGoods));
    }

    /**
     * 修改视频管理
     */
    @PreAuthorize("@ss.hasPermi('cms:goods:edit')")
    @Log(title = "视频管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AaGoods aaGoods)
    {
        return toAjax(aaGoodsService.updateAaGoods(aaGoods));
    }

    /**
     * 删除视频管理
     */
    @PreAuthorize("@ss.hasPermi('cms:goods:remove')")
    @Log(title = "视频管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aaGoodsService.deleteAaGoodsByIds(ids));
    }
}
